const router = require('koa-router')(); //引入router 并调用
const {postLogData} =require("../utils/misc")
// const ObjectId = require('mongodb').ObjectId

const mongo = require('../compents/mongo')
    // 设置根路径
router.prefix('/users')

// 测试
router.get('/test', async ctx => {
    console.log(ctx);
    ctx.body = 'test'
})

// 获取后台数据
router.get('/list', async ctx => {
    let { limit, page, where } = ctx.query
    const res = await mongo.find('users', { limit: limit * 1, page: page * 1 })
    const total = await mongo.count('users', { where })
    ctx.body = { data: res, code: 20000, total, message: "端口求成功" }
})



module.exports = router //导出路由对象